Start a New Discussion Ask a New Question

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Cannot print brochure to correct page size
  •  I wrote the script below, but no matter what I do, I can't seem to get the output in anything except A4 paper size. The brochure command is through the pdfforge.dll, which I don't see source code for anywhere.

    The papersize issues within PDF Creator have been a pain the in the butt for as long as I've been using it (5 years at least). 

    A work around may be to print to A4 (two places to change it in printer preferences in the control panel) and then print again, scaling to Letter size.

     

     


     

    <tt>&nbsp;' This always prints to paper size A4, even if PDFCreator is set up to print to</tt>

    <tt>' a different size, and even if printing to the alternate size works for</tt>

    <tt>' non-brochure printing.</tt>

    <tt><br /></tt>

    <tt>' Apparently, the PDFCreator user interface needs to be open before printing</tt>

    <tt>' Otherwise, the action is not performed during printing and it is missing the</tt>

    <tt>' next time the UI is opened.</tt>

    <tt>Option Explicit</tt>

    <tt><br /></tt>

    <tt>' added to the end of the filename when outputting the brochure</tt>

    <tt>Const suffix = &quot;_brochure&quot;</tt>

    <tt><br /></tt>

    <tt>' filenames and other strings</tt>

    <tt>Dim ifname, ofname</tt>

    <tt>' settings to remember</tt>

    <tt>Dim DefaultPrinter, closed</tt>

    <tt>' objects</tt>

    <tt>Dim objArgs, fso, PDFCreator</tt>

    <tt>' script stuff</tt>

    <tt>Dim i, AppTitle, Scriptname, ScriptBasename</tt>

    <tt>&nbsp;</tt>

    <tt>Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)</tt>

    <tt><br /></tt>

    <tt>Scriptname = fso.GetFileName(Wscript.ScriptFullname)</tt>

    <tt>ScriptBasename = fso.GetFileName(Wscript.ScriptFullname)</tt>

    <tt><br /></tt>

    <tt>AppTitle = &quot;PDFCreator - &quot; &amp; ScriptBaseName</tt>

    <tt><br /></tt>

    <tt>If CDbl(Replace(WScript.Version,&quot;.&quot;,&quot;,&quot;)) &lt; 5.1 then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>MsgBox &quot;You need the &quot;&quot;Windows Scripting Host version 5.1&quot;&quot; or greater!&quot;, _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbCritical + vbSystemModal, AppTitle</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Wscript.Quit 1</tt>

    <tt>End if</tt>

    <tt><br /></tt>

    <tt>Set objArgs = WScript.Arguments</tt>

    <tt>If objArgs.Count = 0 Then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>MsgBox &quot;Syntax: &quot; &amp; vbtab &amp; Scriptname &amp; &quot; &lt;Filename&gt;&quot; &amp; vbcrlf &amp; _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbtab &amp; &quot;or use &quot;&quot;Drag and Drop&quot;&quot;!&quot;, _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbExclamation + vbSystemModal, AppTitle</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>WScript.Quit 1</tt>

    <tt>End If</tt>

    <tt><br /></tt>

    <tt>' initialize and save some settings</tt>

    <tt>Set PDFCreator = Wscript.CreateObject(&quot;PDFCreator.clsPDFCreator&quot;, &quot;PDFCreator_&quot;)</tt>

    <tt>PDFCreator.cStart '&quot;/NoProcessingAtStartup&quot;</tt>

    <tt>With PDFCreator</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>DefaultPrinter = .cDefaultprinter</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>closed = .cIsClosed</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cDefaultprinter = &quot;PDFCreator&quot;</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>' some attempts at getting the papersize to work... failed</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cOption(&quot;UseAutosave&quot;) = 1</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cOption(&quot;UseAutosaveDirectory&quot;) = 1</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cOption(&quot;AutosaveFormat&quot;) = 0<span class="Apple-tab-span" style="white-space:pre"> </span>' 0 = PDF</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cOption(&quot;UseFixPapersize&quot;) = 1</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>' The paper size reported changes according to the setting,&nbsp;</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>' but the brocure function still ignores the setting</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>MsgBox &quot;PaperSize: &quot; &amp; .cOption(&quot;Papersize&quot;)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cOption(&quot;PaperSize&quot;) = &quot;letter&quot;</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>MsgBox &quot;PaperSize: &quot; &amp; .cOption(&quot;Papersize&quot;)</tt>

    <tt><br /></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cSaveOptions<span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cClearcache</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cPrinterStop = false</tt>

    <tt>End With</tt>

    <tt><br /></tt>

    <tt>' create the brochures for each input file given</tt>

    <tt>For i = 0 to objArgs.Count - 1</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>ifname = objArgs(i)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If Not CheckInputFile(ifname) Then Exit For</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>ofname = fso.GetParentFolderName(ifname) &amp; &quot;\&quot; &amp; _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>fso.GetBaseName(ifname) &amp; suffix &amp; &quot;.pdf&quot;</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If Not CheckOutputFile(ofname) Then Exit For</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt>MsgBox &quot;Processing brochure... &quot; &amp; vbCrLf &amp; _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>&quot; &nbsp;Input: &quot; &amp; vbTab &amp; ifname &amp; vbCrLf &amp; _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>&quot; &nbsp;Output:&quot; &amp; vbTab &amp; ofname &amp; vbCrLf</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>CreateBrochure ifname, ofname</tt>

    <tt>MsgBox &quot;Processing &quot; &amp; ifname &amp; &quot; done.&quot;</tt>

    <tt>Next</tt>

    <tt><br /></tt>

    <tt>' clean up PDFCreator and set settings back to their original settings</tt>

    <tt>With PDFCreator</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cDefaultprinter = DefaultPrinter</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>.cClearCache</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>WScript.Sleep 200</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If closed then .cClose</tt>

    <tt>End With</tt>

    <tt>WScript.Quit 0</tt>

    <tt><br /></tt>

    <tt>'-------------------------------------------------------------------------------</tt>

    <tt><br /></tt>

    <tt>Function CheckInputFile (filename)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If Not fso.FileExists(filename) Then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>MsgBox &quot;Can't find the file: &quot; &amp; filename, _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbExclamation + vbSystemModal, AppTitle</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>CheckInputFile = False</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Exit Function</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>End If</tt>

    <tt>&nbsp;</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Dim ext</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>ext = fso.GetExtensionName(filename)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If Ucase(ext) &lt;&gt; &quot;PDF&quot; And Ucase(ext) &lt;&gt; &quot;TMP&quot; Then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>MsgBox &quot;This script works only with pdf files!&quot; &amp; vbCrLf &amp; _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>&quot;Extension '&quot; &amp; ext &amp; &quot;' was given.&quot;, _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbExclamation + vbSystemModal, AppTitle</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>CheckInputFile = False</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Exit Function</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>End If</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>CheckInputFile = True</tt>

    <tt>End Function</tt>

    <tt><br /></tt>

    <tt>Function CheckOutputFile (filename)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Dim vbResponse</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbResponse = -1</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If fso.FileExists(filename) Then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbResponse = MsgBox(&quot;The file already exists. Do you want to replace it?&quot; &amp; vbcrlf &amp; vbcrlf &amp; _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>&quot;File: &quot; &amp; filename, _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbOKCancel, AppTitle)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>End If</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If vbResponse = vbCancel Then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>CheckOutputFile = False</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Exit Function</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>ElseIf vbResponse = vbOK Then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>fso.DeleteFile(filename)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>' see if it actually got deleted</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>If fso.FileExists(filename) Then</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>MsgBox &quot;The file could not be deleted. Skipping.&quot; &amp; vbcrlf &amp; vbcrlf &amp; _</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>&quot;File: &quot; &amp; filename</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>vbResponse = vbCancel</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>End If</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Else</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>' file doesn't exist, so we don't need to worry about it</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>End If</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span></tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>CheckOutputFile = True</tt>

    <tt>End Function</tt>

    <tt><br /></tt>

    <tt>Function CreateBrochure(ifname, ofname)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Dim pdf</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Set pdf = WScript.CreateObject(&quot;pdfforge.pdf.pdf&quot;)</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>pdf.Brochure ifname, ofname</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>Set pdf = Nothing</tt>

    <tt><span class="Apple-tab-span" style="white-space:pre"> </span>CreateBrochure = True</tt>

    <tt>End Function</tt>

  • Hi,

     

    any solution for this problem? Or a tip, how I can change the page size while creating the brochure?

     

    I have PDFs with a format of e.g. 160x230mm. After creating the brochure, the PDF is 297x210mm and the pages are placed on the bottom left. Please help me.

     

    Regards

  • The brochure methode in pdfforge.dll version 2.3.0.0 has been improved. Now you have a lot of page sizes available and you can define your own brochure page size.

    Frank
    Team pdfforge
  • It doesn't matter wchich paper format I choose or client client size I set - it always prints on A4 format.

    I need 80x60mm labels.

  • Have you tested the new brochure methods of the new pdfforge.dll?

    public int Brochure(
    string sourceFilename,
    string destinationFilename,
    float width,
    float height,
    int pageAlign
    )
    public int Brochure(
    string sourceFilename,
    string destinationFilename,
    string pageSize,
    int pageOrientation,
    int pageAlign
    )

    C# sample


    PDF pdf = new PDF();
    pdf.CreatePDFTestDocument("input.pdf", 16, "This is an example.", true);
    pdf.Brochure("input.pdf", "output.pdf", 297, 210, 1);
    pdf = null;
    Frank
    Team pdfforge
  •  I was previously in the 1.3 version of PDF creator. Had difficulty printing Microsoft Word document in landscape format into PDF in landscape format.

    I read the FAQ about Printer --> Server settings and searched out the printer icon looking for Server settings to no avail. 

    Downloaded the 1.4version (initially without the expert settings) and same result. Downloaded the 1.4version again with the expert settings and server installation, thinking it would provide the Server settings. I still do not see this with the print icon.

    Additionally, after control print (with print preferences set to landscape), it appears on the bottom bar of Microsoft Word that the PDF is being created and completed, however, the usual PDF Creator in the middle of the page doesn't come up. Also the window with the document name, creation date and author with the save button doesn't pop up.

    I'm unsure where the newly created PDF is now to even check if it is now in landscape or still portrait.

    For now, it seems that the version 1.4 is rendered not working until I can understand where the "completed" copy is going without triggering the document name, dates, author, etc.