Hi, I have some code which tries to make a multi-page PDF, but when I try to open the PDF in Preview on my Mac, it says
[quote]The file “TracePlots.pdf” could not be opened.
It may be damaged or use a file format that Preview doesn’t recognize.[/quote]
The code which generates the pdf looks like this:
[code] // Already have trees called C1,C2,C3,C3 with TVector branches called ampl_tv.
TCanvas *cTracePlots[N_TRACEPLOTS];
TGraph *gChan1;
TGraph *gChan2;
TGraph *gChan3;
TGraph *gChan4;
// Now we loop over all the entries
Int_t n_entries = C1->GetEntries();
for(Int_t i=0; i < n_entries; i++ )
{
// Make trace plots.
if( i < N_TRACEPLOTS )
{
cTracePlots[i] = new TCanvas();
cTracePlots[i]->Divide(2,2);
if( i == 0 ) cTracePlots[i]->Print(dir_to_plot+"/TracePlots.pdf[",“pdf”);
cTracePlots[i]->cd(1);
C1->Draw("ampl_tv->fElements:Iteration$ >> gChan1",TString::Format("Entry$==%i",i));
gChan1 = (TGraph*)gDirectory->Get("gChan1");
gChan1->SetTitle(TString::Format("Channel 1 Entry %i",i));
cTracePlots[i]->cd(2);
C2->Draw("ampl_tv->fElements:Iteration$ >> gChan2",TString::Format("Entry$==%i",i));
gChan2 = (TGraph*)gDirectory->Get("gChan2");
gChan2->SetTitle(TString::Format("Channel 2 Entry %i",i));
cTracePlots[i]->cd(3);
C3->Draw("ampl_tv->fElements:Iteration$ >> gChan3",TString::Format("Entry$==%i",i));
gChan3 = (TGraph*)gDirectory->Get("gChan3");
gChan3->SetTitle(TString::Format("Channel 3 Entry %i",i));
cTracePlots[i]->cd(4);
C4->Draw("ampl_tv->fElements:Iteration$ >> gChan4",TString::Format("Entry$==%i",i));
gChan4 = (TGraph*)gDirectory->Get("gChan4");
gChan4->SetTitle(TString::Format("Channel 4 Entry %i",i));
gPad->Modified();
gPad->Update();
cTracePlots[i]->Print(dir_to_plot+"/TracePlots.pdf","pdf");
if( i == N_TRACEPLOTS ) cTracePlots[i]->Print(dir_to_plot+"/TracePlots.pdf]","pdf");
}[/code]
When I used the same code to produce multiple single-page PDF files, it worked fine (though I was using SaveAs then, rather than Print).
Any ideas or solutions would be appreciated.