Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Page backgrounds
  FAQ FAQ  Forum Search   Register Register  Login Login

Page backgrounds

 Post Reply Post Reply
Author
Message
StanMarshall View Drop Down
Beginner
Beginner


Joined: 11 Jan 06
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote StanMarshall Quote  Post ReplyReply Direct Link To This Post Topic: Page backgrounds
    Posted: 15 Jun 06 at 4:24PM

Hi all...

I have written (using Delphi 5 and QuickPDF) an application that produces personalized reports for everyone in a supplied data file. I am also given a PDF file to use as the background or "shell" (like a "shell" in the world of offset printing) for the report. (The shell portion of the report is the same for everyone.)

The PDF file I end up producing contains many reports (one for each person in the datafeed).

Currently my application reads in the shell PDF file, adds it to the PDF file I create as a hidden page, and then clones it for each report. (This prevents me from having to include the shell PDF in the file multiple times...thus keeping the file size and RIPping time down.)

Then, for each individual in the datafeed, my application draws whatever personalized info is required we need to over the shell.

This has worked wonderfully up to now. It can be viewed in Acrobat and GSView. It has printed successfully on many printers. The pages are correctly identified as the number page they are (i.e., page 1 is shown as page 1). etc.

But now a printing company we are partnering with wants to print them via an automated tracking system they have in place. It pre-flights the files and reports that the PDFs are corrupt. They say that there is some "offset marker" that is incorrectly stating where "page 1" of the file starts in the print file data stream.

Through trial and error, we have come to suspect that the problem is with the hidden page that I am using for cloning. If you count the hidden page, then "page 1" of the file (which is shown as page 1 and correctly identified as page one by Acrobat) is really page 2.

Has anyone run into this issue? Have any suggestions for fixing it? Or another approach to using the same page background (loaded from an external PDF file) over and over without having to include it in the file multiple times?

Thanks.

Stan

Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jun 06 at 2:17PM
You should append the "shell" to the end of a new PDF, capture it (which removes it from the document), then stamp it onto each new page using DrawCapturedPage(). No need for a hidden page.

This also keeps the file size small, since the captured page is a PDF template, and is stored only once in the PDF. For example, I have a PDF template with a letterhead graphic that is 19,630 bytes. Stamped onto each page of a seven-page report using DrawCapturedPage(), and writing text to each page, the total output file size is just 26,947 bytes.
Back to Top
StanMarshall View Drop Down
Beginner
Beginner


Joined: 11 Jan 06
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote StanMarshall Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jun 06 at 5:16PM

thanks chicks!!

i'll give that approach a try.

Back to Top
chicks View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 29 Oct 05
Location: United States
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicks Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jun 06 at 6:18PM
Here's an example (vbscript) that reads a .txt file from a mainframe (with pagebreaks every nn lines), writes each page to a new PDF page, and stamps a letterhead graphic from another PDF file on each page.

Option Explicit

Const ForReading = 1
Const ForWriting = 2
Const Portrait      = "Letter"
Const Landscape = "Letter Landscape"

Dim QP, QuickPDFKey, srcFileName, destFileName, fso, src, lne, text, page, textSize
Dim fontID, docID
Dim templateFileName
Dim lines, maxLen

'-- Init iSedQuickPDF and FSO objects
Set QP = CreateObject("iSED.QuickPDF")
Set fso = CreateObject("Scripting.FileSystemObject")

'-- Set file names
QuickPDFKey             = WScript.Arguments(0)
srcFileName             = WScript.Arguments(1) '-- Text file to convert to PDF
destFileName            = WScript.Arguments(2) '-- Output PDF filename
templateFileName        = WScript.Arguments(3) '-- Letterhead PDF template filename

'-- Unlock the PDF library
Call QP.UnlockKey(QuickPDFKey)

'-- Open the text file for reading
Set src = fso.OpenTextFile(srcFileName, ForReading)

page     = 0
lines     = 0
maxLen     = 0
fontID     = 0

'-- Load PDF Template
docID = LoadTemplate(templateFileName)

Do Until src.AtEndOfStream
     
     '-- Read a line from text file
     lne = src.ReadLine & VbCr

     '-- If pagebreak is found
     If Left(lne,1) = Chr(12) Then
          '-- Write text to the template
          WritePage
          text = Mid(lne, 2)
          lines = 1
          maxLen = 0
     Else
          '-- Add the line to buffer
          text = text & lne
          lines = lines + 1
          If Len(lne) > maxLen Then
               maxLen = Len(lne)
          End If
     End If
Loop

'-- Write final page
WritePage

'-- Compress the file size
Call QP.CompressContent()

'-- Write to PDF file
Call QP.SaveToFile(destFileName)

Set fso = Nothing
Set src = Nothing
Set QP = Nothing

'-- Write the text to PDF page
'-- Use simple logic to set text and page size
Sub WritePage

     '-- Increment page counter
     page = page + 1

     '-- Create new PDF page
     If page > 1 Then
          Call QP.NewPage()
     End If

     '-- Set origin to top left corner
     Call QP.SetOrigin(1)

     '-- Select current page
     Call QP.SelectPage(page)

     '-- Set to portrait or landscape
     If maxLen > 100 Then
          Call QP.SetPageSize(Landscape)
     Else
          Call QP.SetPageSize(Portrait)
     End If

     '-- Draw the template onto current page
     Call QP.DrawCapturedPage(docID, 0, 0, QP.PageWidth(), QP.PageHeight())

     '-- Select Courier (fixed) font
     If fontID = 0 Then
          fontID = QP.AddStandardFont(0)
     End If
     Call QP.SelectFont(fontID)

     '-- Set text size
     If maxLen > 100 Then
          textSize = 8
     ElseIf lines > 80 Then
          textSize = 7
     ElseIf lines > 66 Or maxLen > 81 Then
          textSize = 8
     Else
          textSize = 10
     End If
     Call QP.SetTextSize(textSize)

     '-- Print info
     WScript.Echo "Page:             " & page
     WScript.Echo "Lines:            " & lines
     WScript.Echo "Max Line Length: " & maxLen
     WScript.Echo "Text Size:        " & textSize
     WScript.Echo ""

     '-- Draw report text onto template
     Call QP.DrawMultiLineText(72, 108, VbCr, text)

End Sub

'-- Load template PDF, capture first page, and return its ID
Function LoadTemplate(templateFileName)
     If QP.LoadFromFile(templateFileName) = 0 Then
          WScript.Echo("Could Not Load PDF Template: " & templateFileName)
          WScript.Quit(1)
     End If
     Call QP.SetOrigin(1)
     Call QP.NewPage()
     Call QP.SelectPage(1)
     LoadTemplate = QP.CapturePage(1)
End Function
Back to Top
StanMarshall View Drop Down
Beginner
Beginner


Joined: 11 Jan 06
Location: United States
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote StanMarshall Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jun 06 at 4:02PM

chicks,

this approach worked wonderfully.

thanks a lot!!

stan

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store