I create a pdf from html with
call HTMLViewer1.PrintToPDFFileMBS(tempItem, 50, 50, 50, 50)
which I then embed into another pdf and add a header and page numbers:
[code]dim thePDFDoc as CGPDFDocumentMBS = thePDFFile.OpenAsCGPDFDocumentMBS
dim pageCount as Integer = thePDFDoc.PageCount
dim finalPDF as CGContextMBS = newPrintPath.NewCGPDFDocumentMBS(thePDFDoc.MediaBox(1), left(theSubject, 100), theMessageID, App.ApplicationNameMBS)
'loop through pages and add header information
for currentPage as Integer = 1 to pageCount
dim theRect as new CGRectMBS
theRect = thePDFDoc.MediaBox(currentPage)
if theRect = nil then Return
finalPDF.BeginPage theRect
finalPDF.DrawCGPDFDocument(thePDFDoc, theRect, currentPage)
if PDFPrintHeader then
DrawPDFHeader(finalPDF, theSubject, 50, theRect.Height - 35)
end if
DrawPDFHeader(finalPDF, str(currentPage) + "/" + str(pageCount), theRect.Width - 50, theRect.Height - 35)
'page is finished
finalPDF.EndPage
next
finalPDF.Flush[/code]
Now I want to change the PrintToPDFFileMBS to
dim PDFData as MemoryBlock = me.RenderDocumentToPDFMBS
which doesn’t have margins. I see how to use a CGDataProviderMBS to create the pdf:
dim theProvider as CGDataProviderMBS = CGDataProviderMBS.CreateWithData(PDFData)
dim thePDFDoc as CGPDFDocumentMBS = CGOpenPDFDocumentMBS(theProvider)
But how do I scale the original pdf so that it fits into the MediaBox of the new one? Changing the CGRectMBS didn’t do anything.