Upgrading from Kentico 9 - 11.0.9. Getting Document

Regis Wengel asked on May 19, 2018 00:41

I can't figure out the new API calls for Kentico 11 for the following (I upgraded from 9).

Document sourceDocument = new File(FileHelper.GetFullFolderPhysicalPath("~/App_Data/CompanyName/PDFTemplates/") + PdfTemplateFilename).Document;
PrimitiveComposer composer = new PrimitiveComposer(sourceDocument.Pages[0]);

I'm not sure if this is the right question, but File() is throwing the error. It's looking for a reference. The File() doesn't seem to be sufficient anymore, but I can't find a replacement.

Recent Answers


Trevor Fayas answered on May 21, 2018 15:01

I'm not seeing a File.Document field even in Kentico 9, did you check the namespace?

I would look at your v9 instance and see what namespace your File class is from, and then tell us here so we can help further (hover over it to see where it's from or click on it and go f12)

0 votesVote for this answer Mark as a Correct answer

Regis Wengel answered on May 21, 2018 18:30 (last edited on May 21, 2018 18:31)

It seems to be taken of the File.File() type

Image 1

Image 2

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on May 21, 2018 19:55

Not exactly what I was looking for. Classes generally have a namespace they belong to, ex ValidationHelper belongs to the CMS.Helpers namespace (so the class is really CMS.Helpers.ValidationHelper). What's the full class name with it's namespace so I can figure out which "File" class it is.

0 votesVote for this answer Mark as a Correct answer

Regis Wengel answered on May 21, 2018 20:37

Here is the namespace Namespace

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on May 21, 2018 21:48

Thank you, that is what i was looking for.

PDFClown is a 3rd party tool that Kentico uses, so it's not really run by Kentico.

However, try adding this to the top of your code:

using org.pdfclown.files;
using org.pdfclown.documents;
using org.pdfclown.documents.contents.composition;

That should properly set the namespaces for your code snippet so it knows to use the pdfcloud namespaces for File, Document, and PrimitiveComposer. If that doesn't resolve the issue, then i'll need to know what error it's throwing.

0 votesVote for this answer Mark as a Correct answer

Regis Wengel answered on May 21, 2018 22:04

Those lines already were attached to the top of the code. I figured out the error though, so no help is longer needed. I appreciate the time and assistance, thank you!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.